﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using famails.iface;
using famails.dao;
using famails.App_Code.source.dto;
namespace famails.bus
{
    /// <summary>
    /// Summary description for ArticleBUS
    /// </summary>
    public class CM_CustomerBUS : ICM_Customer
    {
        CM_CustomerDAO cateDao;
        public CM_CustomerBUS()
        {
            cateDao = new CM_CustomerDAO();
        }

        #region IArticle Members

        public DataTable GetByID(decimal ID, int UserID)
        {
            return cateDao.GetByID(ID, UserID);
        }

        #endregion


        public DataTable Search(string email, string phone, string name, int groupid, int userid, string from, string to)
        {
            return cateDao.Search( email, phone, name, groupid, userid,  from,  to);
        }

        public object Insert(CM_CustomerDTO dto)
        {
            return cateDao.Insert(dto);
        }

        public bool Edit(CM_CustomerDTO dto)
        {
            return cateDao.Edit(dto);
        }

        public bool Delete(int id)
        {
            return cateDao.Delete(id);
        }

        public bool CheckExistsEmail(string email, int id, int userid)
        {
            return cateDao.CheckExistsEmail(email, id, userid);
        }
        public bool CheckBeforDelete(int id)
        {
            return cateDao.CheckBeforDelete(id);
        }

        internal decimal CustomerCare_GetCustomerCountByGroupID(int groupid, int userid)
        {
            return cateDao.CustomerCare_GetCustomerCountByGroupID(groupid, userid);
        }

        internal void DeleteCustomer(string Email, int UserID)
        {
            cateDao.DeleteCustomer(Email, UserID);
        }
    }
}